package com.victor.pomelo.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.victor.pomelo.dao.GroupMapper;
import com.victor.pomelo.model.Group;
import com.victor.pomelo.model.Node;
import com.victor.pomelo.service.GroupService;

@Service
public class GroupServiceImpl implements GroupService {
	@Autowired
	private GroupMapper groupMapper;

	@Override
	public Group createGroup(Group group) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Group updateGroup(Group group) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void deleteGroup(Long groupId) {
		// TODO Auto-generated method stub

	}

	@Override
	public Group findById(Long groupId) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Group> findAll() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void move(Group source, Group target) {
		// TODO Auto-generated method stub

	}

	@Override
	public List<Group> findChild(Long groupid) {
		return groupMapper.findChild(groupid);
	}

	@Override
	public List<Node> findChildren(Long groupid, Integer level) {
		List<Node> rtnlst = new ArrayList<Node>();
		List<Group> lst = groupMapper.findChildren(groupid);
		for (Group group : lst) {
			Node node = new Node();
			node.setLevel(level);
			node.setObj(group);
			rtnlst.add(node);
		}
		return rtnlst;
	}
}
